//-
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

include /app/helpers/jade/mixins
include /app/configuration/mixins

-var form = 'odbcConfiguration'
-var model = '$ctrl.clonedCluster.odbc'
-var enabled = model + '.odbcEnabled'

panel-collapsible(
    ng-form=form
    on-open=`ui.loadPanel('${form}')`
    ng-show='$ctrl.available(["1.0.0", "2.1.0"])'
)
    panel-title ODBC configuration
    panel-description
        | ODBC server configuration.
        | #[a.link-success(href="https://apacheignite.readme.io/docs/odbc-driver" target="_blank") More info]
    panel-content.pca-form-row(ng-if=`$ctrl.available(["1.0.0", "2.1.0"]) && ui.isPanelLoaded('${form}')`)
        .pca-form-column-6.pc-form-grid-row
            .pc-form-grid-col-60
                +form-field__checkbox({
                    label: 'Enabled',
                    model: enabled,
                    name: '"odbcEnabled"',
                    tip: 'Flag indicating whether to configure ODBC configuration'
                })(
                    ui-validate=`{
                        correctMarshaller: '$ctrl.Clusters.odbc.odbcEnabled.correctMarshaller($ctrl.clonedCluster, $value)'
                    }`
                    ui-validate-watch='$ctrl.Clusters.odbc.odbcEnabled.correctMarshallerWatch("$ctrl.clonedCluster")'
                )
                    +form-field__error({ error: 'correctMarshaller', message: 'ODBC can only be used with BinaryMarshaller' })
            .pc-form-grid-col-60
                +form-field__ip-address-with-port-range({
                    label: `${model}.endpointAddress`,
                    model: '$item.localOutboundHost',
                    name: '"endpointAddress"',
                    enabled,
                    placeholder: '0.0.0.0:10800..10810',
                    tip: 'ODBC endpoint address. <br/>\
                          The following address formats are permitted:\
                          <ul>\
                              <li>hostname - will use provided hostname and default port range</li>\
                              <li>hostname:port - will use provided hostname and port</li>\
                              <li>hostname:port_from..port_to - will use provided hostname and port range</li>\
                          </ul>'
                })
            .pc-form-grid-col-30
                +form-field__number({
                    label: 'Send buffer size:',
                    model: `${model}.socketSendBufferSize`,
                    name: '"ODBCSocketSendBufferSize"',
                    disabled: `!(${enabled})`,
                    placeholder: '0',
                    min: '0',
                    tip: 'Socket send buffer size.<br/>\
                          When set to <b>0</b>, operation system default will be used'
                })
            .pc-form-grid-col-30
                +form-field__number({
                    label:'Socket receive buffer size:',
                    model: `${model}.socketReceiveBufferSize`,
                    name: '"ODBCSocketReceiveBufferSize"',
                    disabled: `!(${enabled})`,
                    placeholder: '0',
                    min: '0',
                    tip: 'Socket receive buffer size.<br/>\
                          When set to <b>0</b>, operation system default will be used'
                })
            .pc-form-grid-col-30
                +form-field__number({
                    label: 'Maximum open cursors',
                    model: `${model}.maxOpenCursors`,
                    name: '"maxOpenCursors"',
                    disabled: `!(${enabled})`,
                    placeholder: '128',
                    min: '1',
                    tip: 'Maximum number of opened cursors per connection'
                })
            .pc-form-grid-col-30
                +form-field__number({
                    label: 'Pool size:',
                    model: `${model}.threadPoolSize`,
                    name: '"ODBCThreadPoolSize"',
                    disabled: `!(${enabled})`,
                    placeholder: 'max(8, availableProcessors)',
                    min: '1',
                    tip: 'Size of thread pool that is in charge of processing ODBC tasks'
                })
        .pca-form-column-6
            +preview-xml-java(model, 'clusterODBC')
